Current Location: Home> Function Categories> strptime

strptime

parse the time/date generated by strftime
Name:strptime
Category:Date and time
Programming Language:php
One-line Description:Parses the time/date generated by strftime().

Definition and usage

strptime() function parses the time/date generated by strftime() .

Note: This function is not implemented on the Windows platform.

Example

Parses the time/date generated by strftime():

 <?php
$format = "%d/%m/%Y %H:%M:%S" ;
$strf = strftime ( $format ) ;
echo ( " $strf " ) ;
print_r ( strptime ( $strf , $format ) ) ;
?>

grammar

 strptime ( date , format ) ;
parameter describe
date Required. The string to parse (for example: returned by strftime()).
format

Required. The format to be used in the specified date:

  • %a - Abbreviation of the day of the week
  • %A - The full name of the day of the week
  • %b - Abbreviation of the month name
  • %B - The full name of the month name
  • %c - preferred date and time notation
  • %C - a number representing the century (year divided by 100, ranging from 00 to 99)
  • %d - What day of the month (01 to 31)
  • %D - Time format, same as %m/%d/%y notation
  • %e - What day of the month (1 to 31)
  • %g - Similar to %G notation, but without century
  • %G - 4-digit year corresponding to the ISO week number (see %V)
  • %h - Same as %b notation
  • %H - hours, on a 24-hour schedule (00 to 23)
  • %I - hours, using a 12-hour system (01 to 12)
  • %j - What day of the year (001 to 366)
  • %m - Month (01 to 12)
  • %M - points
  • %n - newline
  • %p - am or pm corresponding to the given time value
  • %r - time stamping method of am and pm
  • %R - 24-hour time stamping method
  • %S - seconds
  • %t - tab tab character
  • %T - Current time, the same as the %H:%M:%S representation
  • %u - The number of the day of the week (1 to 7), Monday [Monday] = 1. Warning: On Sun Solaris system, Sunday [Sunday] = 1
  • %U - The number of weeks included in the year, starting from the first Sunday, as the first day of the first week
  • %V - The number of weeks (01 to 53) contained in the ISO 8601 format included in the year. Week 1 means that the first week of the year must have at least four days, and Monday is the first day of the week
  • %W - The number of weeks included in the year, starting from the first Monday, as the first day of the first week
  • %w - represents a day of the week in decimal form, Sunday [Sunday] = 0
  • %x - preferred date notation without time
  • %X - preferred time notation without date
  • %y - A representation of year that does not contain a number representing the century (range from 00 to 99)
  • %Y - A representation of the year that contains the number representing the century
  • %Z or %z - Time zone name or abbreviation
  • %% - Output a % character
Similar Functions
Popular Articles